<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app">
    <ul>
      <li v-for="item in books">{{ item }}</li>
    </ul>
    <input type="button" value="修改" @click="changeBook">
    <input type="button" value="测试" @click="fn02">
    <p>msg:{{ msg }}</p>
    <p>str:{{ str }}</p>
  </div>
  <script src="./js/vue.js"></script>
  <script>
    let vm = new Vue({
      el: "#app",
      data: {
        books: ["大学", "中庸"],
        str: "hi"
      },
      methods: {
        changeBook() {

          // 1、非响应式情况一：对数组使用了 **非变异 (non-mutating method) 方法
          // this.books.map(item=>item+1);
          // 2、非响应式情况二： 修改数组的长度时
          // this.books.length = 5;
          // 3、非响应式情况三： 使用数组的索引（根索引)的方式改变数组的元素时
          
          this.books[0] = "论语";
          this.$forceUpdate();//强制刷新
          // this.books.splice(0,1,"论语");
          console.log("this.books", this.books);
        },
        fn02() {
          // this.msg += "1";
          // console.log("this.msg",this.msg);                
          this.str += "1";
          console.log("this.str", this.str);
          console.log("this.arr", this.arr);
        }
      }
    })

    console.log("vm.books", vm.books);
    //4、非响应式情况三：  给对象添加新的属性时
    vm.msg = "hello";//这样给对象增加的属性不是响应式的。
    vm.arr = ["三国演义"];


  </script>
</body>

</html>